{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python38664bite0826404ec9f4f88a00ca1565c140931",
   "display_name": "Python 3.8.6 64-bit"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "'''\n",
    "*args: 还可以使用任意数量的参数来调用函数，这些参数会包含在一个元组里。\n",
    "在*args之前，可能出现0个或者多个普通参数。\n",
    "可变参数被放在形式参数列表的末尾，因为他们收集传递给函数的所有输入参数。\n",
    "在*args之后的任何形参，只能是关键字参数，不用通过位置调用。\n",
    "'''\n",
    "\n",
    "def write_multiple_items(file, sep, *args): # *args 之前可以出现任意数量的普通参数\n",
    "    file.write(sep.join(args))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "&#39;User/watalo/Desktop&#39;"
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "source": [
    "def concat(*args, sep=\"/\"):\n",
    "    return sep.join(args)\n",
    "\n",
    "concat('User','watalo','Desktop')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": "&#39;math.bio.bs-model&#39;"
     },
     "metadata": {},
     "execution_count": 3
    }
   ],
   "source": [
    "concat('math','bio','bs-model',sep='.') # *args 之后只能使用 关键字参数调用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}